package com.sc.test.utils;

import com.sc.test.bean.News;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.HTTP;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;

/**
 * Created by Shen Chao on 2017-12-27-027.
 */

public interface AppUrls {
    /**
     * @param path 占位符 替换成index
     * @return 请求结果
     */
    @GET("toutiao/{path}")
    Call<ResponseBody> getNewsUrl(@Path("path") String path);

    @GET("toutiao/index")
    Call<ResponseBody> getNewsUrlAndKey(@Query("key") String key);

    @GET("toutiao/index")
    Call<News> getNewsUrlAndKeyReturnBean(@Query("key") String key);

    @POST("toutiao/index")
    Call<News> getNewsPost(@Query("key") String key);

    @FormUrlEncoded
    @POST("toutiao/index")
    Call<News> getNewsPostForm(@Field("key") String key, @Field("type") String type);

    @FormUrlEncoded
    @POST("toutiao/index")
    Call<News> getNewsPostMap(@FieldMap Map<String, String> map);

    @HTTP(method = "GET", path = "toutiao/index")
    Observable<News> getNews(@Query("type") String type, @Query("key") String key);

}
